oo::class create StatusBar {
    superclass Monitor
    variable StatusBar

    constructor {parent} {
        my createStatusBar $parent
    }

    method createStatusBar {parent} {
        set StatusBar [frame $parent.status]
        pack [ttk::sizegrip $StatusBar.sizegrip] -side right
        pack [ttk::separator $StatusBar.sep0 -orient vertical] -side right -padx 3 -fill y
        pack [ttk::label $StatusBar.modified -text modified -state disable] -side right
        pack [ttk::separator $StatusBar.sep1 -orient vertical] -side right -padx 3 -fill y
        pack [ttk::checkbutton $StatusBar.readonly -text readonly -command [list [self object] toggleReadOnly]] -side right
        pack [ttk::separator $StatusBar.sep2 -orient vertical] -side right -padx 3 -fill y
        pack [ttk::label $StatusBar.language] -side right
        pack [ttk::separator $StatusBar.sep3 -orient vertical] -side right -padx 3 -fill y
        pack [ttk::label $StatusBar.size -width 13 -text "size: "] -side right
        pack [ttk::separator $StatusBar.sep4 -orient vertical] -side right -padx 3 -fill y
        pack [ttk::label $StatusBar.column -width 13 -text "colunm: "] -side right
        pack [ttk::separator $StatusBar.sep5 -orient vertical] -side right -padx 3 -fill y
        pack [ttk::label $StatusBar.row -width 10 -text "row: "] -side right
        pack [ttk::separator $StatusBar.sep6 -orient vertical] -side right -padx 3 -fill y
	pack $StatusBar -side bottom -fill x
    }

    method update {textWidget langObj} {
        foreach p {updateModifiedInfo updateColumnInfo
            updateRowInfo updateSizeInfo} {
            my $p $textWidget
        }
        my updateLanguageInfo [string trimleft [info object class $langObj] :]
    }

    method updateModifiedInfo {widget} {
        if [$widget edit modified] {
            set editState normal
        } else {
            set editState disable
        }
        $StatusBar.modified configure -state $editState
    }

    method updateLanguageInfo {language} {
        $StatusBar.language configure -text $language
    }

    method updateColumnInfo {widget} {
        $StatusBar.column configure -text \
            "column: [lindex [split [$widget index insert] .] 1]"
    }

    method updateRowInfo {widget} {
        $StatusBar.row configure -text \
            "row: [expr int([$widget index insert])]"
    }

    method updateSizeInfo {widget} {
        $StatusBar.size configure -text \
            "size: [$widget count -chars 1.0 end-1c]c"
    }

    method toggleReadOnly {} {
        set var [$StatusBar.readonly cget -variable]
        set ns ::[string trimleft [join [lreplace [split $var :] end end] ::] :]
        set padWidget [set ${ns}::Container].pad
        # puts "$padWidget -> [expr {[set $var] == 1 ? "disable" : "normal"}]"
        $padWidget configure -state [expr {[set $var] == 1 ? "disable" : "normal"}]
        
        if [set $var] {
            $padWidget configure -background #E6E6E6
        } else {
            $padWidget configure -background #ffffff
        }
    }

    destructor {
        destroy $StatusBar
    }
}